//
//  BridgeTestNativeViewController.m
//  app
//
//  Created by yanjunliang on 2024/12/24.
//

#import "BridgeTestNativeViewController.h"
#import "bridgeUtil.h"

@interface BridgeTestNativeViewController ()

@end

@implementation BridgeTestNativeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self setNavigationBarWithCenterTitle:self.titleName];
    
    self.plugin = [bridgeUtil getBridge];
    
    UIButton* sendMessageBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width/4, 200, self.view.frame.size.width/2, 50)];
    sendMessageBtn.backgroundColor = [UIColor blueColor];
    sendMessageBtn.layer.cornerRadius = 25;
    [sendMessageBtn setTitle:@"发送消息" forState:UIControlStateNormal];
    [sendMessageBtn addTarget:self action:@selector(sendMessageFun) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:sendMessageBtn];
    
    UIButton* callMethodBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width/4, 400, self.view.frame.size.width/2, 50)];
    callMethodBtn.backgroundColor = [UIColor blueColor];
    callMethodBtn.layer.cornerRadius = 25;
    [callMethodBtn setTitle:@"方法调用" forState:UIControlStateNormal];
    [callMethodBtn addTarget:self action:@selector(callMethodFun) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:callMethodBtn];
}

- (void)sendMessageFun {

    [self.plugin sendMessage:@[@"message", @"from", @"ios"]];
}

- (void)callMethodFun {
    MethodData* method = [[MethodData alloc] initMethodWithName:@"jsMethod" parameter:nil];
    [self.plugin callMethod:method];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
